package com.keyinong.caizhengting.tools;

import android.content.Context;
import android.content.SharedPreferences;
import android.content.SharedPreferences.Editor;

/**
 * @author：郑谦
 * @时间：2017-3-10 上午10:13:22
 * @类名：SetAndGetDataUtil.java
 * @功能: 保存数据的工具类
 */
public class SetAndGetDataUtil {
    private static SharedPreferences sp;

    @SuppressWarnings("static-access")
    public static void SetData(Context context, String filename, String key,
                               String value) {
        sp = context.getSharedPreferences(filename, context.MODE_PRIVATE);
        Editor editor = sp.edit();
        editor.putString(key, value);
        editor.commit();
    }

    @SuppressWarnings("static-access")
    public static String GetData(Context context, String filename, String key) {
        String value = "";
        sp = context.getSharedPreferences(filename, context.MODE_PRIVATE);
        value = sp.getString(key, "");
        return value;
    }
}
